package com.ebox.core.exception;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ebox.core.utils.EboxUtils;

public class EboxException extends RuntimeException {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static Logger log = LoggerFactory.getLogger(EboxException.class);

	public EboxException() {
		super();
	}

	/**
	 * 支持传参数给异常描述字符串进行合并
	 * 
	 * @param errID
	 * @param args
	 */
	public EboxException(int errID) {
	
		
		if (EboxUtils.isNotEmpty(errID)) {
			String errMsg = "异常编号：" + errID;
		
			System.out.println(errMsg);
		} else {
			System.out.println("没有查询到异常编号为[" + errID + "]的异常配置信息。");
		}
	}

	
	/**
	 * 直接打印简单信息
	 * 
	 * @param pMsg
	 * @param pNestedException
	 */
	public EboxException(String pMsg) {
		super(pMsg);
		log.error(pMsg);
	}

	/**
	 * 直接打印简单信息和异常堆栈
	 * 
	 * @param pMsg
	 * @param pNestedException
	 */
	public EboxException(String pMsg, Throwable pNestedException) {
		super(pMsg);
		pNestedException.printStackTrace();
	}
	
	/**
	 * 直接打印异常堆栈
	 * 
	 * @param pMsg
	 * @param pNestedException
	 */
	public EboxException(Throwable pNestedException) {
		super(pNestedException);
		pNestedException.printStackTrace();
	}

}
